package middleware

import (
	"context"
	"fmt"

	"github.com/nsqio/go-nsq"

	"bilinadmin/pkg/mq"
)

// MqRequestId request id
func MqRequestId(handler mq.MqHandlerFunc) mq.MqHandlerFunc {
	return func(ctx context.Context, msg *nsq.Message) (err error) {
		ctx = context.WithValue(ctx, "_requestID", fmt.Sprintf("%s", msg.ID))
		return handler(ctx, msg)
	}
}
